﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using ThietBiSo.LinQDB;
using ThietBiSo.Models;

namespace ThietBiSo.Controllers
{
    public class lienheController : Controller
    {
        //
        // GET: /lienhe/
        MLienHe mlh = new MLienHe();
        LienHe lh = new LienHe();

        MFormLienHe mflh = new MFormLienHe();
        FormLienHe flh = new FormLienHe();
        public ActionResult Index()
        {
            var v = mlh.FindAll_Web();
            ViewData["lienhes"] = v;
            return View();
        }

      
        public ActionResult lienhe()
        {


            var v = mlh.FindAll();
            ViewData["lienhes"] = v;

            var vflh = mflh.FindAll();
            ViewData["formlienhes"] = vflh;
            return View();
        }

        [HttpPost]
        public ActionResult lienhe(FormCollection collection)
        {
            try
            {

                lh.Id = 1;
                lh.NoiDung = System.Net.WebUtility.HtmlDecode(collection.Get("ChiTiet"));
                mlh.Update(lh);
                return RedirectToAction("lienhe");
            }
            catch
            {
                return View();
            }
        }

    }
}
